<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;

/**
 * Class SendMailController
 *
 * @Route("mail")
 */
class SendMailController extends AbstractController
{
    /**
     * @Route("/send/mail", name="send_mail")
     */
    public function index()
    {
        return $this->render('send_mail/index.html.twig', [
            'controller_name' => 'SendMailController',
        ]);
    }


	/**
	 * @Route("/send/{name}")
	 */
	public function sendMail($name, \Swift_Mailer $mailer)
	{
		$message = (new \Swift_Message('Hello Email'))
			->setFrom('send@example.com')
			->setTo('recipient@example.com')
			->setBody(
				$this->renderView(
				// templates/emails/registration.html.twig
					'emails/registration.html.twig',
					['name' => $name]
				),
				'text/html'
			);

		$mailer->send($message);
		return $this->render('emails/registration.html.twig',
			[
				'name' => $name
			]);

	}
}
